package com.archetypus.projectschedule.web.projects.cmd;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.archetypus.projectschedule.common.Configuration;
import com.archetypus.projectschedule.common.dto.projects.ProjectListHandler;
import com.archetypus.projectschedule.common.exceptions.ProjectSchedulerException;
import com.archetypus.projectschedule.web.common.cmd.ICommand;
import com.archetypus.projectschedule.web.projects.bd.IProjectBD;
import com.archetypus.projectschedule.web.projects.bd.ProjectBD;

public class ListProjectsCmd implements ICommand {

	public void execute(HttpServletRequest request, HttpServletResponse response)
			throws ProjectSchedulerException {
		IProjectBD projectBD = new ProjectBD();
		try {
			ProjectListHandler projectLH = projectBD.listProjects();
			request.setAttribute("projectList", projectLH.getList());
			request.setAttribute("pageSize", Configuration.getInstance().get("pageSize"));
		} catch (ProjectSchedulerException e) {
			throw e;
		}
	}

}
